package org.visionlibrary.image.geomtric.model;

public class LinearFunction implements LinearFunction1d {
	private double a;
	private double b;
	
	public LinearFunction() {
		this(1, 0);
	}
	
	public LinearFunction(double a, double b) {
		this.a = a;
		this.b = b;
	}
	
	@Override
	public double evaluateY(double x) {
		return a*x + b;
	}
	
	@Override
	public double evaluateX(double y) {
		return (y - b)/a;
	}
	
	@Override
	public double getDirectionFactor() {
		return a;
	}
	
	@Override
	public String toString() {
		return new String("y = " + a + "*x +" + b);
	}
}
